--=========================================================
--科目数据
--=========================================================
--华东物流
CREATE TABLE [dbo].[t_jiuqi_subject_hdwl](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--朱家桥
CREATE TABLE [dbo].[t_jiuqi_subject_zjq](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--上海
CREATE TABLE [dbo].[t_jiuqi_subject_sh](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--仓储
CREATE TABLE [dbo].[t_jiuqi_subject_cc](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--广州
CREATE TABLE [dbo].[t_jiuqi_subject_gz](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--杭州
CREATE TABLE [dbo].[t_jiuqi_subject_hz](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--合肥
CREATE TABLE [dbo].[t_jiuqi_subject_hf](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--江苏
CREATE TABLE [dbo].[t_jiuqi_subject_js](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--昆明
CREATE TABLE [dbo].[t_jiuqi_subject_km](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--联运(芜湖)
CREATE TABLE [dbo].[t_jiuqi_subject_lywh](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--联运
CREATE TABLE [dbo].[t_jiuqi_subject_ly](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--南京
CREATE TABLE [dbo].[t_jiuqi_subject_nj](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--武汉
CREATE TABLE [dbo].[t_jiuqi_subject_wh](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--本部
CREATE TABLE [dbo].[t_jiuqi_subject_bb](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--镇江
CREATE TABLE [dbo].[t_jiuqi_subject_zj](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--重庆
CREATE TABLE [dbo].[t_jiuqi_subject_cq](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--斯迪尔电子
CREATE TABLE [dbo].[t_jiuqi_subject_sdedz](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);
--斯迪尔钢铁
CREATE TABLE [dbo].[t_jiuqi_subject_sdegt](
  code VARCHAR(100),--科目代码
  NAME VARCHAR(100),--科目名称
  mnemonic_code VARCHAR(100),--助记码
  direction VARCHAR(10),--0 借   1 贷
  attribute VARCHAR(100),--科目属性
  clazz VARCHAR(100),--科目类别
  assist_accounting_type  VARCHAR(100),--辅助核算类型
  enable_current_account VARCHAR(10),--启用往来账
  cash_flow_attribute  VARCHAR(100),--现金流属性
  debit_project  VARCHAR(100),--借方项目
  credit_project  VARCHAR(100),--贷方项目
  spec_subject  VARCHAR(100),--特殊余额项目
  parent_code VARCHAR(100),--父科目代码
  company_id INT,
  leaf INT,--0 不是叶子 1是叶子
  remarks VARCHAR(100),
  status INT
);


--华东物流
update dbo.t_jiuqi_subject_hdwl set company_id=7807;
--朱家桥
update dbo.t_jiuqi_subject_zjq set company_id=6966;
--上海
update dbo.t_jiuqi_subject_sh set company_id=5880;
--仓储
update dbo.t_jiuqi_subject_cc set company_id=7789;
--广州
update dbo.t_jiuqi_subject_gz set company_id=6189;
--杭州
update dbo.t_jiuqi_subject_hz set company_id=5888;
--合肥
update dbo.t_jiuqi_subject_hf set company_id=5881;
--江苏
update dbo.t_jiuqi_subject_js set company_id=6611;
--昆明
update dbo.t_jiuqi_subject_km set company_id=5886;
--联运芜湖
--update dbo.t_jiuqi_subject_lywh set company_id=null;
--联运
update dbo.t_jiuqi_subject_ly set company_id=6528;
--南京
update dbo.t_jiuqi_subject_nj set company_id=5882;
--武汉
update dbo.t_jiuqi_subject_wh set company_id=5885;
--本部
update dbo.t_jiuqi_subject_bb set company_id=6185;
--镇江
update dbo.t_jiuqi_subject_zj set company_id=5883;
--重庆
update dbo.t_jiuqi_subject_cq set company_id=5884;
--斯迪尔电子
--update dbo.t_jiuqi_subject_sdedz set company_id=null;
--斯迪尔钢铁
--update dbo.t_jiuqi_subject_sdegt set company_id=null;

--华东物流
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_hdwl;
--朱家桥
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_zjq;
--上海
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_sh;
--仓储
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_cc;
--广州
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_gz;
--杭州
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_hz;
--合肥
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_hf;
--江苏
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_js;
--昆明
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_km;
--联运芜湖
--insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
--                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
--  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
--    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
--    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_lywh;
--联运
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_ly;
--南京
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_nj;
--武汉
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_wh;
--本部
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_bb;
--镇江
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_zj;
--重庆
insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_cq;
--斯迪尔电子
--insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
--                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
-- select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
--    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
--    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_sdedz;
--斯迪尔钢铁
--insert into dbo.t_jiuqi_subject(code,name,mnemonic_code,direction,attribute,clazz,
--                                assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,parent_code,company_id,status)
--  select code,ltrim(rtrim(name)),mnemonic_code,direction,attribute,clazz,
--    assist_accounting_type,enable_current_account,cash_flow_attribute,debit_project,credit_project,spec_subject,
--    case when len(code)!=4 then substring(code,1,len(code)-2) else null end,company_id,'1' from  dbo.t_jiuqi_subject_sdegt;

